package com.example.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.ArrayList;
import java.util.List;

@Configuration
public class WebMVCConfig implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //addPathPatterns为拦截途径，excludePathPatterns为放行路径
        // 白名单
        List<String> patterns = new ArrayList<String>();
        patterns.add("/employee/login");
        patterns.add("/employee/logout");
        patterns.add("/backend/api/**");
        patterns.add("/backend/images/**");
        patterns.add("/backend/js/**");
        patterns.add("/backend/plugins/**");
        patterns.add("/backend/styple/**");
        patterns.add("/backend/page/login/login.html");
        patterns.add("/front/page/login.html");
        patterns.add("/front/api/**");
        patterns.add("/front/images/**");
        patterns.add("/front/fonts/**");
        patterns.add("/front/js/**");
        patterns.add("/front/styles/**");
        patterns.add("/common/**");
        patterns.add("/user/gainVerCode");
        patterns.add("/user/login");
        patterns.add("/user/loginout");
        // 通过注册工具添加拦截器
        registry.addInterceptor(new loginEmployeeIntercetor()).addPathPatterns("/**").excludePathPatterns(patterns);
    }
}